package com.yezao.processor.ktFile

import com.yezao.processor.ktFile.apis.KtMethod
import java.lang.StringBuilder

data class KtClassMethod(
    val scope:String,//方法范围 public protect
    val methodName:String,//方法名
    val resultType:String?,//返回类型名
    val paramsArray:ArrayList<String>//入参类型列表
){


    var bodyContent:String?=""
    fun writeMethodContent(content:String){
        this.bodyContent = content
    }
    override fun toString():String{
        val stringBuilder = StringBuilder()
        // public fun       foo
        stringBuilder.append(scope)
        stringBuilder.append(" ")
        stringBuilder.append("fun(")
        for (param in paramsArray) {
            stringBuilder.append(param.toLowerCase())
            stringBuilder.append(":")
            stringBuilder.append(param)
        }
        stringBuilder.append(")")
        resultType?.run {
            stringBuilder.append(":")
            stringBuilder.append(resultType)
        }
        stringBuilder.append("{\n")//方法体开始
        bodyContent?.run {
            stringBuilder.append(this)
        }
        stringBuilder.append("\n}")//方法体结束
        return stringBuilder.toString()
    }
}
